import Vue from 'vue';
import Router from 'vue-router';
import ProjectHome from '@/views/ProjectHome';
import Home from '@/views/Home';
import Info from '@/views/Info';
import Interest from '@/views/Interest';
import OrderDetails from '@/views/OrderDetails';
import Record from '@/views/Record';
import Repayment from '@/views/Repayment';
import RepayResult from '@/views/RepayResult';
import Result from '@/views/Result';
import Agreement from '@/views/Agreement';
import AccountIntest from '@/views/AccountIntest';
import Qrcodepay from '@/views/QrcodePay';
import AccountRecord from '@/views/AccountRecord';
import LoanRecord from '@/views/LoanRecord';


Vue.use(Router);

export default new Router({
  routes: [
    {
      path: '/',
      name: 'Home',
      component: Home,
    },
    {
      path: '/mer/:merId',
      name: 'Home',
      component: Home,
      props:true
    },
    {
      path: '/projectHome',
      name: 'ProjectHome',
      component: ProjectHome
    },
    {
      path: '/info',
      name: 'Info',
      component: Info,
      beforeEnter:function  (to,from,next) {
        console.dir(from);
        if(from.name == "Qrcodepay"){
            location.hash="#/record";
        }else{
            next();
        }
      }
    },
    {
      path: '/interest',
      name: 'Interest',
      component: Interest,
      beforeEnter:function  (to,from,next) {
        console.dir(from);
        if(from.name == "Agreement"){
            window.isGetLoanMoney = true;
        }
        next();
      }
    },
    {
      path: '/orderDetails',
      name: 'OrderDetails',
      component: OrderDetails,
    },
    {
      path: '/record',
      name: 'Record',
      component: Record,
    },
    {
      path: '/repayment',
      name: 'Repayment',
      component: Repayment,
    },
    {
      path: '/repayResult',
      name: 'RepayResult',
      component: RepayResult,
    },
    {
      path: '/result',
      name: 'Result',
      component: Result,

    },{
      path: '/agreement/:id',
      name: 'Agreement',
      component: Agreement,
    },{
      path: '/accountIntest',
      name: 'AccountIntest',
      component: AccountIntest,
    },{
      path: '/qrcodepay',
      name: 'Qrcodepay',
      component: Qrcodepay,
    },{
      path: '/repayMent',
      name: 'Repayment',
      component: Repayment,
    },{
      path: '/accountRecord',
      name: 'AccountRecord',
      component: AccountRecord,
    },{
      path: '/loanRecord',
      name: 'LoanRecord',
      component: LoanRecord,
    },
  ],
});
